<?php namespace Home\Controller;
use Hdphp\Controller\Controller;
/*
 * 公共控制器用来处理公共部分数据
 * */
class CommonController extends Controller{

public function __construct(){
    parent::__construct();
	//获得左侧四条顶级分类
	$rightCatedata = Db::table("category")->where("pid",0)
	->orderBy("cid","DESC")
	->limit(4)
	->get();
  View::with("rightCatedata",$rightCatedata);
	
	
   //点击排行
    $rightClickdata=Db::table("article")
    ->field("aid","title")
    ->where("is_recycle",0)
    ->limit(8)->get();

	View::with("rightClickdata",$rightClickdata);
	
	//最新文章
	$rightNewdata= Db::table("article")->where("is_recycle",0)->limit(8)
	->orderBy("sendtime","DESC")
	->limit(3)
	->get();

	View::with("rightNewdata",$rightNewdata);
	
	//右侧的分类
	$catedata = Db::table("category")->get();
	foreach ($catedata as $k => $v) {
	$catedata[$k]['total'] = Db::table("article")
		->where("category_cid",$v['cid'])->count();
	}
	View::with("catedata",$catedata);
	
	//标签云
	$tagdata = Db::table("tag")->get();
	View::with("tagdata",$tagdata);
	
	//友情链接
	$linkdata = Db::table("link")->get();
	View::with("linkdata",$linkdata);

   }
}
